example 1
example 2
example 3
example 4
example 5
/*In this simulation we will test the two motors that the robot contains, one for each caterpillar, making them turn forwards and backwards,turning on the yellow LED in case of going forward*/ /*We include the appropriate libraries to be able to activate certain commands and instructions*/ #include <Wire.h> #include <Zumo32U4.h> /*We name the components that are going to be used, in this case the two motors and the A button to activate the simulation*/ Zumo32U4Motors motors; Zumo32U4ButtonA buttonA; /*In void setup we write what is related to the interaction with the user*/ void setup() { /*We order the robot to remain deactivated until the user does not press the A button*/ buttonA.waitForButton(); /*We put a delay of one second so that the user has time to remove the hand from the robot before the maneuver begins*/ delay(1000); } /*In void loop we structure all the steps that the motor should follow during the simulation, repeatedly*/ void loop() { /*We activate the yellow LED and ask the left motor to advance the caterpillar, from a speed of 0 to 400, with a total delay value of 16, after which it will stop*/ ledYellow(1); for (int speed = 0; speed <= 400; speed++) { motors.setLeftSpeed(speed); delay(8); } for (int speed = 400; speed >= 0; speed--) { motors.setLeftSpeed(speed); delay(8); } /*We deactivate the yellow LED and ask the left motor to move the caterpillar backwards, from a speed of 0 to -400, with a total delay value of 16, after which it will stop*/ ledYellow(0); for (int speed = 0; speed >= -400; speed--) { motors.setLeftSpeed(speed); delay(8); } for (int speed = -400; speed <= 0; speed++) { motors.setLeftSpeed(speed); delay(8); } /*We desactivate the yellow LED and ask the right motor to advance the caterpillar, from a speed of 0 to 400, with a total delay value of 16, after which it will stop*/ ledYellow(1); for (int speed = 0; speed <= 400; speed++) { motors.setRightSpeed(speed); delay(8); } for (int speed = 400; speed >= 0; speed--) { motors.setRightSpeed(speed); delay(8); } /*We deactivate the yellow LED and ask the right motor to move the caterpillar backwards, from a speed of 0 to -400, with a total delay value of 16, after which it will stop*/ ledYellow(0); for (int speed = 0; speed >= -400; speed--) { motors.setRightSpeed(speed); delay(8); } for (int speed = -400; speed <= 0; speed++) { motors.setRightSpeed(speed); delay(8); } /*we apply a delay of two seconds before the other motor test that I have created, which is exactly the same but activating both motors at the same time*/ delay(2000); ledYellow(1); for (int speed = 0; speed <= 400; speed++) { motors.setLeftSpeed(speed); motors.setRightSpeed(speed); delay(4); } for (int speed = 400; speed >= 0; speed--) { motors.setLeftSpeed(speed); motors.setRightSpeed(speed); delay(4); } ledYellow(0); for (int speed = 0; speed >= -400; speed--) { motors.setLeftSpeed(speed); motors.setRightSpeed(speed); delay(4); } for (int speed = -400; speed <= 0; speed++) { motors.setLeftSpeed(speed); motors.setRightSpeed(speed); delay(4); } /*Finally we apply another delay of 2 seconds, after which the first test will be repeated*/ delay(2000); } Video of the Circuit
Video of the Circuit